package com.nageoffer.shortlink.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nageoffer.shortlink.admin.common.convention.result.Result;
import com.nageoffer.shortlink.admin.remote.dto.ShortLinkRemoteService;
import com.nageoffer.shortlink.admin.remote.dto.req.ShortLinkCreateReqDTO;
import com.nageoffer.shortlink.admin.remote.dto.req.ShortLinkPageReqDTO;
import com.nageoffer.shortlink.admin.remote.dto.resp.ShortLinkCreateRespDTO;
import com.nageoffer.shortlink.admin.remote.dto.resp.ShortLinkPageRespDTO;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 刘新智
 * @Date: 2025/10/20 19:11
 * @Description: 短链接控制层
 * @Version: v1.0
 */
@RestController
@RequestMapping("api/shortlink/admin/v1/link")
@AllArgsConstructor
public class ShortLinkController {

    /**
     * @description: 短链接分页查询
     * @author: 刘新智
     * @date: 2025/10/23 13:48
     * @param: [requestParam]
     * @return: com.nageoffer.shortlink.admin.common.convention.result.Result<com.baomidou.mybatisplus.core.metadata.IPage<com.nageoffer.shortlink.admin.remote.dto.resp.ShortLinkPageRespDTO>>
     **/
    @PostMapping("/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageShortLink(@RequestBody ShortLinkPageReqDTO requestParam) {
        ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService(){};
        return shortLinkRemoteService.pageShortLink(requestParam);
    }

    /**
     * @description: 创建短链接
     * @author: 刘新智
     * @date: 2025/10/23 13:48
     * @param: [requestParam]
     * @return: com.nageoffer.shortlink.admin.common.convention.result.Result<com.nageoffer.shortlink.admin.remote.dto.resp.ShortLinkCreateRespDTO>
     **/
    @PostMapping("/create")
    public Result<ShortLinkCreateRespDTO> createShortLink(@RequestBody ShortLinkCreateReqDTO requestParam) {
        ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService(){};
        return shortLinkRemoteService.createShortLink(requestParam);
    }
}